import java.util.Scanner;

public class test1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = scan.nextInt();
        int[] arr = new int[n];
        for(int i = 0;i < n;i++){
            arr[i] = scan.nextInt();
        }
        int count = -1;

        for(int i = 0 ; i < n ; i++){
            count = -1;
            int tmp = arr[i];
//            int m5 = tmp/5;
//            if(tmp%5==0){
//                System.out.println(m5);
//
//            }
            for(int m5 = tmp/5;m5>=0;m5--){
                int m51 = tmp-(m5*5);
                if(m51%3==0){
                    count = m5+(m51/3);
                    break;
                }
            }
            System.out.println(count);
        }

        scan.close();
    }
}
